package guoanmaker.operator.business.controller;

import guoanmaker.operator.business.service.Operator2AppServiceInterface;
import guoanmaker.operator.business.service.OperatorCityServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;


/**
 *  
 *
 * @ClassName: Operator2AppController
 * @author: huZhaoyu 
 * @date 2017/7/11 下午5:43 
 */
@RestController
@RequestMapping(ApiController.OPERATOR_2APP)
public class Operator2AppController {
    private final Operator2AppServiceInterface operator2AppServiceInterface;
    private final OperatorCityServiceInterface operatorCityServiceInterface;

    public Operator2AppController(Operator2AppServiceInterface operator2AppServiceInterface, OperatorCityServiceInterface operatorCityServiceInterface) {
        this.operator2AppServiceInterface = operator2AppServiceInterface;
        this.operatorCityServiceInterface = operatorCityServiceInterface;
    }

    @ApiOperation(value = "app接口", notes = "app接口")
    @RequestMapping(value = "/2app", method = RequestMethod.GET)
    public AjaxJson getAll2App(@RequestParam(value = "cityId") String cityId){
    	AjaxJson ajaxJson=new AjaxJson();
        ajaxJson.setSuccess(true).setStatus(200).setData(operator2AppServiceInterface.getAll2App(cityId));
        return ajaxJson;
    }

    @ApiOperation(value = "定位开通城市", notes = "定位开通城市")
    @GetMapping(value = "getOpenCity2App")
    public AjaxJson getOpenCity2App(@RequestParam(value = "cityName") String cityName,@RequestParam(value = "username") String username,@RequestParam(value = "landType") String landType) {
    	AjaxJson ajaxJson=new AjaxJson();
    	try{
    	HashMap remep=operatorCityServiceInterface.getCity2App(cityName,username,landType);
    	ajaxJson.setSuccess(true).setStatus(200).setData(remep).setMsg("请求成功");
    	}catch(Exception e){
    		e.printStackTrace();
    		ajaxJson.setSuccess(false).setStatus(250).setData(null);
    	}
        return ajaxJson;
    }

}
